<script setup>
  import { getCsrfToken } from '@/helpers/context'
  import Button from './Button.vue'

  const props = defineProps({
    label: { type: String },
    extendedLabel: { type: String },
    icon: String,
    showLabel: { type: Boolean, default: false },
    css: { type: String, default: '' },
    title: { type: String, default: '' },
    url: { type: String, required: true },
  })
  const emits = defineEmits(['click'])

  let csrf_token = getCsrfToken()
  if (!csrf_token) {
    console.error('Missing csrf token in AppOptions')
    csrf_token = 'TOKEN HAS NOT BEEN FOUND IN AppOptions'
  }
</script>
<template>
  <form :action="url" method="post" class="btn-container">
    <input type="hidden" name="csrf_token" :value="csrf_token" />
    <Button
      :label="label"
      :extendedLabel="extendedLabel"
      :show-label="showLabel"
      :icon="icon"
      :css="css"
      :title="title"
      type="submit"
    />
  </form>
</template>
